package model1

/**
 * @author: guangcheng
 * @date:   2020/11/22 11:22
 * @version  V1.0
 * @description:
 *
 */
type Student struct {
	Name string
	Age  int
}

//体现了封装性
type person struct {
	Name string
	Age  int
	sex  string //私有(封装)字段
}

//伪构造器
func NewPerson(Name string, Age int) *person {
	return &person{
		Name: Name,
		Age:  Age,
	}
}

//伪满参构造
func NewPersonAllArgs(Name string, Age int, Sex string) *person {
	return &person{
		Name: Name,
		Age:  Age,
		sex:  Sex, //私有字段需要内部间谍获取(getter)
	}
}

//伪get(), 用于访问封装的字段
func (person *person) GetSex() string {
	//内部间谍偷偷拿到数据, 交给外部敌人
	return (*person).sex
}
